# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-iocextract
pkgname=('python2-iocextract' 'python-iocextract')
_pkgname=iocextract
pkgver=1.16.1
pkgrel=3
pkgdesc='Defanged Indicator of Compromise (IOC) Extractor.'
arch=('any')
url='https://pypi.org/project/iocextract/#files'
license=('GPL')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('3f359758f6ebab7144071b88ca8d5dc972a6a0903ae409eb10e5ea7bb2b635e00466dc5ec78e8d9d7fa24bf4942939e6d952f7c31bc3772bc33b97bdd43815fc')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-iocextract() {
  depends=('python2' 'python2-ipaddress' 'python2-regex')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${_pkgname}2"
}

package_python-iocextract() {
  depends=('python' 'python-ipaddress' 'python-regex')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

